package cn.joyfulmedia.mis.service;


import cn.joyfulmedia.common.util.page.Pagination;
import cn.joyfulmedia.dao.ExamMisRoleMapper;
import cn.joyfulmedia.entity.ExamMisRole;
import cn.joyfulmedia.mis.service.interfaces.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service("roleService")
public class RoleServiceImpl implements RoleService {
    @Autowired
    private ExamMisRoleMapper roleDao;

    @Override
    public Integer saveRole(ExamMisRole entity) throws Exception {
        return roleDao.saveRole(entity);
    }


    @Override
    public Integer updateRoleById(ExamMisRole entity) throws Exception {
        return roleDao.updateRoleById(entity);
    }

    @Override
    public ExamMisRole selectRoleById(Object id) throws Exception {
        return roleDao.selectRoleById(id);
    }

    public Integer listPageCount(ExamMisRole role) {
        return this.roleDao.listPageCount(role);
    }

    @Override
    public List<ExamMisRole> listPage(ExamMisRole role, Pagination pagination) {
        List<ExamMisRole> list = new ArrayList<ExamMisRole>();
        int count = this.listPageCount(role);
        if (count > 0) {
            pagination.setTotal(count);
            list = roleDao.listPage(role, pagination);
        }
        return list;
    }

    @Override
    public Integer delPermBYId(Long id) {
        return roleDao.delPermBYId(id);
    }


    @Override
    public Integer bathSavePerm(Long[] rid, Long id) {
        return roleDao.bathSavePerm(rid, id);
    }


    @Override
    public List<ExamMisRole> findByAccountId(Long id) {
        return roleDao.findByAccountId(id);
    }


    @Override
    public Integer delRoleBYId(Long id) {
        return roleDao.delRoleBYId(id);
    }


    @Override
    public Integer bathSaveRole(Long[] rid, Long id) {
        return roleDao.bathSaveRole(rid, id);
    }


}
